package com.cheyun.netsalev3.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.cheyun.netsalev3.R;
import com.cheyun.netsalev3.bean.widget.RadioData;
import com.zhy.view.flowlayout.FlowLayout;
import com.zhy.view.flowlayout.TagAdapter;

import java.util.List;

public class RadioAdapter2 extends TagAdapter<RadioData> {

    private Context context;
    public RadioAdapter2(Context context, List<RadioData> datas) {
        super(datas);
        this.context=context;
    }

    @Override
    public View getView(FlowLayout parent, int position, RadioData data) {
        LayoutInflater inflater = LayoutInflater.from(context);
        View view = inflater.inflate(R.layout.radio_item, parent, false);
        TextView tv = view.findViewById(R.id.tv_oper_name);
        if (!data.getKey().equals("")) {
            tv.setBackground(data.getChecked() ? context.getResources().getDrawable(R.drawable.rectangle_15dp_lan) : context.getResources().getDrawable(R.drawable.rectangle_15dp_hui));
            tv.setText(data.getName());
            tv.setTextColor(data.getChecked() ? context.getResources().getColor(R.color.white) : context.getResources().getColor(R.color.customer_tag));
        }
        return view;
    }
}